<?php

/*
 * 数据有效性验证1
 *
 * error code:
 *  1:无key为trace的post数据
 *  2:trace进行json解析时出错
 *  3:trace中无有效session和uuid
 */
include('path.inc.php');
//包含session操作类
include(PATH . 'includes/class/session.class.php');

//包含公共函数文件
include(PATH . 'includes/function/common.func.php');
if(!isset($_POST['trace'])){
    //post数据出错
    die('error code: 1');
}
if(NULL == ($params = json_decode($_POST['trace'], true))){
    //trace数据格式出错
    var_dump($params);
    die('error code: 2');
}
if(!isset($params['session']) || !isset($params['uuid'])){
    //session丢失
    die('error code: 3');
}

/*
 * 设定session_id，开始缓存数据
 */

$session = new YeahTraceSession($params['session']);

//去除session
unset($params['session']);

//数据存储
$content = json_encode($params);
$session->AddAndRelease($content);

echo $content;

?>
